package top.kaoshanji.p1ch03a;

/**
 * 代码清单-p1ch03a-64页b：表示订单条目的类
 * author kaoshanji
 * ^_^
 * create time 2025/2/17 10:58
 */
public class OrderItem {

    // 购买产品
    private Product product;

    // 购买数量
    private int quantity;

    public OrderItem(Product product, int quantity) {
        this.product = product;
        this.quantity = quantity;
    }

    public double computePrice() {
        return getProduct().getPrice() * getQuantity();
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
}
